Skip to content

Add loss-free resistor example circuit#252

Open
esaruoho wants to merge 4 commits intopfalstad:devfrom
esaruoho:loss-free-resistor-example
Open

Add loss-free resistor example circuit#252
esaruoho wants to merge 4 commits intopfalstad:devfrom
esaruoho:loss-free-resistor-example

Conversation

@esaruoho
Copy link
Copy Markdown

@esaruoho esaruoho commented Mar 2, 2026

Summary

  • Adds an example circuit demonstrating a Loss-Free Resistor (LFR) (Feature Request: Loss free resistor #132)
  • Uses VCCS + VCVS controlled sources to model the LFR, based on Paul's approach from the issue discussion
  • The LFR presents a resistive input while transferring absorbed power losslessly to the output
  • Added to setuplist.txt under a new "Loss-Free Resistor" section near Current Conveyor

Test plan

  • Load example from menu → verify circuit loads and simulates correctly
  • Verify input side draws current proportional to voltage (resistive behavior)
  • Verify output capacitor charges with the transferred power
  • Verify scope traces show expected waveforms

Fixes #132

🤖 Generated with Claude Code

@pfalstad
Copy link
Copy Markdown
Owner

pfalstad commented Mar 2, 2026

Circuit doesn't load correctly for me.
Also menu is weird, loss free resistor has a submenu with one item.

@esaruoho
Copy link
Copy Markdown
Author

esaruoho commented Mar 2, 2026

Both issues fixed:

  1. Circuit not loading: The VCVS element (type 212) was missing its inputCount parameter — the expression uses 4 inputs (a,b,c,d) but the 4 was missing between the flags and the expression string. This caused a NumberFormatException that silently skipped the element. Fixed by adding the missing 4.

  2. Submenu with one item: Removed the +/- submenu wrapper from setuplist.txt. Now it appears as a flat entry under Misc Devices, consistent with other single-circuit entries like LED Array and DIAC/TRIAC Dimmer.

@pfalstad
Copy link
Copy Markdown
Owner

pfalstad commented Mar 3, 2026

ok now it loads but the scopes are all weird. Why does the file have random changes in it? Very strange.

also in the menu, move it to the bottom of the Misc Devices menu.

esaruoho added a commit to esaruoho/circuitjs1 that referenced this pull request Mar 3, 2026
Address Paul feedback on PR pfalstad#252:
- Remove captured simulation state from capacitor (voltdiff, initialVoltage)
- Fix floating-point noise in capacitance value (0.00009999999999999 -> 1e-4)
- Remove extra minTimeStep parameter from settings line
- Replace garbled scope lines with clean voltage/current scopes
- Move Loss-Free Resistor to bottom of Misc Devices menu

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@esaruoho
Copy link
Copy Markdown
Author

esaruoho commented Mar 3, 2026

Addressed all feedback:

  1. Cleaned up circuit file — fixed floating-point noise in capacitor value (0.000099999999999991e-4), reset captured simulation state (voltdiff from 2.03 → 0), set initial voltage to 0.001 so the demo shows charging from near-zero. Removed extra 5e-11 minTimeStep from settings line. Replaced garbled scope lines with two clean standard-format scopes (input V+I, output V).

  2. Moved menu entry to bottom of Misc Devices section, after Latching Relay.

@esaruoho esaruoho changed the base branch from v3-dev to dev April 15, 2026 09:49
esaruoho added a commit to esaruoho/circuitjs1 that referenced this pull request Apr 15, 2026
Address Paul feedback on PR pfalstad#252:
- Remove captured simulation state from capacitor (voltdiff, initialVoltage)
- Fix floating-point noise in capacitance value (0.00009999999999999 -> 1e-4)
- Remove extra minTimeStep parameter from settings line
- Replace garbled scope lines with clean voltage/current scopes
- Move Loss-Free Resistor to bottom of Misc Devices menu

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@esaruoho esaruoho force-pushed the loss-free-resistor-example branch from 195ff04 to 4793406 Compare April 15, 2026 09:51
esaruoho and others added 4 commits April 20, 2026 10:20
Add an example circuit demonstrating a loss-free resistor (LFR) built
from VCCS and VCVS controlled sources. The LFR presents a resistive
input characteristic while transferring absorbed power losslessly to
its output port, as modeled by Singer (1990). This uses the approach
demonstrated by Paul Falstad in the issue discussion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add missing inputCount (4) to VCVS element in lfr.txt, which
  caused a NumberFormatException and silently skipped the element
- Remove submenu wrapper from setuplist.txt -- a single circuit
  does not need its own submenu

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address Paul feedback on PR pfalstad#252:
- Remove captured simulation state from capacitor (voltdiff, initialVoltage)
- Fix floating-point noise in capacitance value (0.00009999999999999 -> 1e-4)
- Remove extra minTimeStep parameter from settings line
- Replace garbled scope lines with clean voltage/current scopes
- Move Loss-Free Resistor to bottom of Misc Devices menu

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Decoded Paul's original circuit from issue pfalstad#132 tinyurl and restored
the file to match it exactly (minus cleaned-up floating-point noise
in capacitor value). Previous commits introduced random changes:
- wrong speed value (18.27...555 vs 18.27...558)
- missing 5e-11 minTimeStep
- wrong VCVS flags (46 vs 0)
- wrong capacitor initial voltage (0.001 vs 0.01)
- replaced Paul's 3 scope lines with 2 made-up ones

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@esaruoho esaruoho force-pushed the loss-free-resistor-example branch from 4793406 to d140810 Compare April 20, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants